package com.MedDroid.activity;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import com.MedDroid.MainApp;
import com.MedDroid.R;
import com.MedDroid.task.AddNewUserTask;

public class AddNewUserActivity extends Activity
{
	public EditText EditLoginName, EditPassword, EditFirstName, EditMiddleName, EditLastName, EditPhoneNumber, EditAddressLine, EditCity, EditProvince, EditCountry, EditPostalCode, EditEmergencyContact, EditEmergencyPhoneNumber;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.new_add_user);

		//Add user
		EditLoginName = (EditText) findViewById(R.id.txtLoginName);
		EditPassword = (EditText) findViewById(R.id.txtPassword);
		EditFirstName = (EditText) findViewById(R.id.txtFirstName);
		EditMiddleName = (EditText) findViewById(R.id.txtMiddleName);
		EditLastName = (EditText) findViewById(R.id.txtLastName);
		EditPhoneNumber = (EditText) findViewById(R.id.txtPhoneNumber);
		EditAddressLine = (EditText) findViewById(R.id.txtAddressLine);
		EditCity = (EditText) findViewById(R.id.txtCity);
		EditProvince = (EditText) findViewById(R.id.txtProvince);
		EditCountry = (EditText) findViewById(R.id.txtCountry);
		EditPostalCode = (EditText) findViewById(R.id.txtPostalCode);
		EditEmergencyContact = (EditText) findViewById(R.id.txtEmergencyContact);
		EditEmergencyPhoneNumber = (EditText) findViewById(R.id.txtEmergencyNumberProfile);

		/*
		final Spinner userTypeSpinner = (Spinner) findViewById(R.id.spnrUserType);
		String userType = userTypeSpinner.getSelectedItem().toString();
		*/

        Button btnSubmit = (Button) findViewById(R.id.btnSubmit);
        btnSubmit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
			MainApp.log("Attempting to add new user.");
			new AddNewUserTask(((MainApp)getApplication()).getDatabase(),AddNewUserActivity.this).execute();
			finish();
            }
        });
    }
}